package info.qingshui.browser;

import info.qingshui.browser.R;
import info.qingshui.browser.hk.index.URLInfo;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class IndexItemClickListener implements OnItemClickListener {
	Activity from;
	Class<?> to;
	public IndexItemClickListener(Activity from, Class<?> to) {
		super();
		this.from = from;
		this.to = to;
	}

	@Override
	public void onItemClick(AdapterView<?> adapter, View view, int position,
			long arg) {
		URLInfo item = (URLInfo) adapter.getItemAtPosition(position);
		Log.i(BaseIndex.class.getSimpleName(), "onListItemClick item.getUrl()="
				+ item.getUrl());
		
		// 通过intent跳转到下一个页面.
		Intent intent = new Intent();
		intent.setClass(from, to);
		// 通过Bundle来获取数据,通过key-Value的方式放入数据
		Bundle bl = new Bundle();
		bl.putString("go_url", item.getUrl());
		// 将Bundle放入Intent传入下一个Activity
		intent.putExtras(bl);
		// 跳到下一个Activity,并且等待其返回结果
		from.startActivity(intent);
		


	}
}
